package cn.ainit.bj.AutorSubmission;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.ainit.bj.AutorSubmission.entity.BjAutorSubmission;
import cn.ainit.common.ReturnObject;
import cn.ainit.sys.utils.UUID32;
@Controller
@RequestMapping("/AutorSubmission")       //修改一个名字
public class AutorSubmissionController {
	
	private AutorSubmissionService AutorSubmissionService;
	@Resource  //参照ServiceImpl中一样
	public void setAutorSubmissionService(AutorSubmissionService AutorSubmissionService) {
		this.AutorSubmissionService = AutorSubmissionService;
	}
	
	@RequestMapping("/saveOrUpdAutorSubmission")
	@ResponseBody
	public ReturnObject saveOrUpdAutorSubmission(BjAutorSubmission bjAutorSubmission,int panduan,HttpServletRequest request) throws Exception{
		ReturnObject returnObject = new ReturnObject();
		try {
			boolean flag = false;
			String hid = "";  
			if (bjAutorSubmission.getJiaogaoId() == null || bjAutorSubmission.getJiaogaoId()=="" || bjAutorSubmission.getJiaogaoId().equals("null") || bjAutorSubmission.getJiaogaoId().equals("")) {
				hid =UUID32.newGuid();
				bjAutorSubmission.setJiaogaoId(hid);
				flag = AutorSubmissionService.saveAutorSubmission(bjAutorSubmission);
				if (flag) {
					returnObject.setMsg("success");
					returnObject.setInfo(hid);
				}else{
					returnObject.setMsg("fail");
				}
			}else{
				flag = AutorSubmissionService.updAutorSubmissionSave(bjAutorSubmission);
				if (flag) {
					returnObject.setMsg("upsuccess");
				}else {
					returnObject.setMsg("fail");
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return returnObject;
	}
	
}
